namespace EyeSoft.Wpf.Facilities
{
	using System;

	using EyeSoft.Timers;

	public static class ViewModelController
	{
		private static readonly Singleton<ILocator> singletonContainer =
			new Singleton<ILocator>();

		public static void Set(ILocator container)
		{
			singletonContainer.Set(container);
		}

		public static ServiceFactory<T> ServiceFactory<T>() where T : IDisposable
		{
			return singletonContainer.Instance.GetInstance<ServiceFactory<T>>();
		}

		public static ITimerFactory TimerFactory()
		{
			return Timers.TimerFactory.Create();
		}

		public static TViewModel Create<TViewModel>() where TViewModel : AutoRegisterViewModel
		{
			return singletonContainer.Instance.GetInstance<TViewModel>();
		}
	}
}